/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package BL;

import Bean.CTDT;
import Bean.CoHoiVL;
import Util.DBConnection;
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author AD_DA
 */
public class BLNganh {
    public List<CTDT> getDS_CTDT(int MaNganh) throws SQLException{
        List<CTDT> listCTDT=new ArrayList<CTDT>();
        String sql="SELECT M.MAMON, TENMON,SOTC, STC_TH, STC_LT, STC_HP "
                + "FROM monhoc M,chuongtrinhdaotao C "
                + "WHERE M.MAMON=C.MAMON AND C.MANGANH= "+MaNganh;
        Connection conn=null;
        conn=DBConnection.getConnection();
        Statement stm=(Statement) conn.createStatement();
        ResultSet rs=stm.executeQuery(sql);
        while(rs.next()){
            CTDT ct=new CTDT();
            ct.setMaMon(rs.getString("MAMON"));
            ct.setTenMon(rs.getString("TENMON"));
            ct.setSoTC(rs.getFloat("SOTC"));
            ct.setSTC_LT(rs.getFloat("STC_LT"));
            ct.setSTC_TH(rs.getFloat("STC_TH"));
            ct.setSTC_HP(rs.getFloat("STC_HP"));
            listCTDT.add(ct);
        }
        conn.close();
        return listCTDT;
    }
    public List<CoHoiVL> getDSCoHoiVL(int MaNganh) throws SQLException{
        List<CoHoiVL> listCoHoiVL= new ArrayList<CoHoiVL>();
        String sql="SELECT C.MANGANH, C.MAVL, V.VIECLAM, C.CACNOILAMVIEC, C.CACCHUCVU "
                + "FROM cohoivieclam C, vieclam V WHERE C.MAVL=V.MAVL AND C.MANGANH="+MaNganh;
        Connection conn=null;
        conn=DBConnection.getConnection();
        Statement stm=(Statement) conn.createStatement();
        ResultSet rs=stm.executeQuery(sql);
        while(rs.next()){
            CoHoiVL chvl=new CoHoiVL();
            chvl.setMaNganh(rs.getInt("MANGANH"));
            chvl.setMaVL(rs.getInt("MAVL"));
            chvl.setTenVL(rs.getString("VIECLAM"));
            chvl.setChucVu(rs.getString("CACCHUCVU"));
            chvl.setNoiLV(rs.getString("CACNOILAMVIEC"));         
            listCoHoiVL.add(chvl);
        };
        conn.close();
        return listCoHoiVL;
    }
}
